/*
 * =====================================================================================
 *
 *       Filename:  socket_connect.c
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2025年05月12日 14时39分58秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  xiaojian jiang (Adams), <yunsangc@163.com>
 *   Organization:  
 *
 * =====================================================================================
 */
#ifndef __SOCKET_CONNECT_H__
#define __SOCKET_CONNECT_H__
#include <ev.h>
#include <pthread.h>

enum SOCKET_CONEECT_STATE {
	NO_CONNECT = 0,
	CONNECTING,
	CONNECTED
};

typedef struct socket_client_ctx
{
	int fd;
	int connect_stat;
	char ipaddr[16];
	int port;
	ev_io connect_io; // 连接 io
	ev_io recv_io; // 接收 io

	uint64_t count;
	uint64_t size;

} client_ctx_t;

extern struct ev_loop *loop;

client_ctx_t *get_client_ctx();
int send_data_by_tcp(const unsigned char* pkg, size_t pkg_len);
void client_ctx_stop();
int socket_client_init(char *ipaddr, int port);

#endif /* ifdef __SOCKET_CONNECT_H__*/
